using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace TankWars.Weapons
{
    class Mine : Shot
    {
        private const int N_MINE_POWER = 50;
        public const int N_TIME_BETWEEN_FIRING = 2000;
        public const int N_MAX_AMMO = 3;
        public const WeaponManager.WeaponCategory SHOT_CATEGORY = WeaponManager.WeaponCategory.Ammo;

        private float fSpeed = 0.0f;

        public Mine(Tank firingTank, Texture2D mineSprite) 
            : base(mineSprite)
        {
            base.FiringTank = firingTank;

            base.nPower = N_MINE_POWER;

            base.fRotation = firingTank.Rotation;
            base.vPosition = firingTank.RearOfTank;
            base.vPosition.X -= (base.SpriteWidth / 2) * (float)Math.Cos(base.fRotation);
            base.vPosition.Y -= (base.SpriteWidth / 2) * (float)Math.Sin(base.fRotation);

            base.vSpeed = new Vector2(this.fSpeed);

            if ((MathHelper.ToDegrees(firingTank.Rotation) < 90)
                || (MathHelper.ToDegrees(firingTank.Rotation) >= 270))
            {
                Vector2.Negate(ref base.vSpeed, out base.vSpeed);
            }
        }

        public Mine(Tank firingTank, Texture2D mineSprite, string strSpriteName, string strFrameXMLFile)
            : base(strSpriteName, mineSprite, strFrameXMLFile)
        {
            base.FiringTank = firingTank;

            base.nPower = N_MINE_POWER;

            base.strExplodeAnimationLabel = "MineExplosion";

            base.fRotation = firingTank.Rotation;
            base.vPosition = firingTank.RearOfTank;
            base.vPosition.X -= (base.SpriteWidth / 2) * (float)Math.Cos(base.fRotation);
            base.vPosition.Y -= (base.SpriteWidth / 2) * (float)Math.Sin(base.fRotation);

            base.vSpeed = new Vector2(this.fSpeed);

            if ((MathHelper.ToDegrees(firingTank.Rotation) < 90)
                || (MathHelper.ToDegrees(firingTank.Rotation) >= 270))
            {
                Vector2.Negate(ref base.vSpeed, out base.vSpeed);
            }
        }
    }
}
